package com.cs.pk.codestriker;

import java.io.IOException;
import java.util.Iterator;
import java.util.List;

import com.cs.pk.utils.ClearCaseException;
import com.cs.pk.utils.UtilRepository;

public class GenerateDiff extends AbstractPopulateList{

	private String vd = null;
	private StringBuffer differences = null;
	public GenerateDiff(Object component) {
		super(component);
		vd = component.toString();
		differences = new StringBuffer();
	}

	protected String filterOutput() {
		if(result!=null) {
			return result.trim();
		}
		return null;
	}

	protected void populate(Object payload) throws IOException,	InterruptedException, ClearCaseException {
		List files = (List)payload;
		String value = null;
		for (Iterator iterator = files.iterator(); iterator.hasNext();) {
			String[] f = (String[]) iterator.next();
			value = runBatFile(new String[] { UtilRepository.DRIVE+":","cd "+vd,"cleartool diff -ser "+ f[1] +" "+ f[0]});
			if(value!=null) {
				differences.append(value);
			}
		}
	}
	
	public String getDifferences() {
		return differences.toString();
	}

	public void clear() {
		
	}

}
